import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView'

const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '',
        component: HomeView,
        children: [
          {
            path: '',
            name: 'DataScreening',
            component: () => import('@/views/Layout/DataScreening'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/leaveMessage',
            name: 'leaveMessage',
            component: () => import('@/views/Layout/leaveMessage'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/TeacherList',
            name: 'TeacherList',
            component: () => import('@/views/Layout/TeacherList'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/StudentFiles',
            name: 'StudentFiles',
            component: () => import('@/views/Layout/StudentFiles'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/professionalManagement',
            name: 'professionalManagement',
            component: () => import('@/views/Layout/professionalManagement'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/CollegeManagement',
            name: 'CollegeManagement',
            component: () => import('@/views/Layout/CollegeManagement'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/ClassList',
            name: 'ClassList',
            component: () => import('@/views/Layout/ClassList'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/SystemSettings/RetrievePassword',
            name: 'RetrievePassword',
            component: () => import('@/views/Layout/SystemSettings/RetrievePassword'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/SystemSettings/LoginRecord',
            name: 'LoginRecord',
            component: () => import('@/views/Layout/SystemSettings/LoginRecord'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/SystemSettings/ChangePassword',
            name: 'ChangePassword',
            component: () => import('@/views/Layout/SystemSettings/ChangePassword'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/StudentManagement/StudentList',
            name: 'StudentList',
            component: () => import('@/views/Layout/StudentManagement/StudentList'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/StudentManagement/Restore',
            name: 'Restore',
            component: () => import('@/views/Layout/StudentManagement/Restore'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/StudentManagement/Graduates',
            name: 'Graduates',
            component: () => import('@/views/Layout/StudentManagement/Graduates'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/PerformanceManagement/ScoreList',
            name: 'ScoreList',
            component: () => import('@/views/Layout/PerformanceManagement/ScoreList'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/PerformanceManagement/ScoreEntry',
            name: 'ScoreEntry',
            component: () => import('@/views/Layout/PerformanceManagement/ScoreEntry'),
            meta: {
              islogin: true
            }
          },
          {
            path: '/PerformanceManagement/ExaminationManagement',
            name: 'ExaminationManagement',
            component: () => import('@/views/Layout/PerformanceManagement/ExaminationManagement'),
            meta: {
              islogin: true
            }
          },
        ],
        meta: {
          islogin: true
        }
      }
    ]
  },
  {
    path: '/Login',
    name: 'Login',
    component: () => import('@/views/login')
  },
  {
    path: '/Error',
    name: 'Error',
    component: () => import('@/views/error'),
  },
  {
    path: '*',
    redirect: '/Error'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
